package com.example.demo.config;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import com.example.demo.entity.Redis;

@Component
// 通过前缀映射
@ConfigurationProperties(prefix = "my")
public class YamlConfig {
	// 后缀对应属性
	private String database;

	@Value("${your.username}")
	private String profiles;

	// 一个key对应多个value，可以使用集合或数组保存数据，数据同时可以映射类
	// 既可以用List也可以使用Set
	// private List<String> servers = new ArrayList<>();
	private Set<String> servers = new TreeSet<>();
	private List<Redis> redis = new ArrayList<>();

	public String getProfiles() {
		return profiles;
	}

	public void setProfiles(String profiles) {
		this.profiles = profiles;
	}

	public Set<String> getServers() {
		return this.servers;
	}

	public List<Redis> getRedis() {
		return this.redis;
	}

	public String getDatabase() {
		return database;
	}

	public void setDatabase(String database) {
		this.database = database;
	}

}
